// 商品数据模型的模块

// 加载模块
const mongoose = require('mongoose')

// 创建Schema对象
const goodsSchema = mongoose.Schema({
    name: {
        type: String,
        required: true
    },
    price: {
        type: String,
        required: true
    },
    desc: {
        type: String,
        required: true
    },
    imgurl: {
        type: String,
        required: true
    },
    type: {
        type: String,
        required: true
    }
})

// 把 schema对象编译成一个 Model 数据模型
const goodsModel = mongoose.model('goods',goodsSchema)

// 对外暴露数据模型
module.exports = goodsModel
